package day10.net2;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) {

        while (true) {
            try (//serverSocket ：服务端套接字
                 ServerSocket ss = new ServerSocket(8888);
                 //2调用accept 返回客户端套接字
                 Socket s = ss.accept();

                 //3获得输入流对象
                 InputStream is = s.getInputStream();) {

                //4定义一个数组
                byte[] b = new byte[10240000];

                int len = 0;
                //5while循环
                while ((len = is.read(b)) > 0) {
                    //6组成String输出
                    String str = new String(b, 0, len);
                    System.out.println(str);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
